﻿using System;
using System.Collections.Generic;
using System.Web;
using PayRoller.Code;
using System.Web.SessionState;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using HySoft.Cash.Business;
using HySoft.Cash.Structure;
using System.Configuration;
using System.Web.Profile;
using HySoft.Cash;

namespace PayRoller.Manage.OrgInfo
{
    public class InvoiceSend : ParentPage, IRequiresSessionState
    {
        // Methods
        protected override void OnInit(EventArgs e)
        {
            base.m_ModuleCode = "0008";
            base.CheckLogin(true);
            base.CheckPerm();
            base.OnInit(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            string str = base.Request["OrgSid"].ToString();
            TinvoicelistBN tbn = new TinvoicelistBN(this.Page);
            TinvoicelistDT detail = new TinvoicelistDT();
            detail.OrgSid = Convert.ToInt32(str);
            detail.InvoiceDate = SafeDateTime.LocalNow;
            detail.InvoiceAmount = 0;
            //detail.IsValid = InvoiceStatuses.Sent;
            detail.SendStatus = InvoiceSendStatuses.Sent;
            if (tbn.Add(detail))
            {
                tbn.Dispose();
                tbn = null;
                base.ClientScript.RegisterStartupScript(base.GetType(), "", "<script>alert('Success!');window.location='InvoicesList.aspx?OrgSid=" + str + "';</script>");
            }
            else
            {
                tbn.Dispose();
                tbn = null;
                base.ClientScript.RegisterStartupScript(base.GetType(), "", "<script>alert('Error!');window.location='InvoicesList.aspx?OrgSid=" + str + "';</script>");
            }
        }

        // Properties
        protected HttpApplication ApplicationInstance
        {
            get
            {
                return this.Context.ApplicationInstance;
            }
        }

        protected DefaultProfile Profile
        {
            get
            {
                return (DefaultProfile)this.Context.Profile;
            }
        }
    }

}
